/**
 * Cider
 * Copyright (c) 2004-2021 All Rights Reserved.
 */
package com.xunk.common.core.enums;

import org.apache.commons.collections4.map.CaseInsensitiveMap;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author 杨文栋
 * @version DeviceEnum.java, v 0.1 2021-03-17 18:41 杨文栋 Exp $$
 */
public enum DeviceCategoryEnum {
    /**
     * 1 网关
     */
    GATEWAY(1),

    /**
     * 2 网关子设备
     */
    GATEWAY_SUBDEVICE(2),

    /**
     * 3 wifi
     */
    WIFI(3),

    UNKNOWN(99);

    /**
     * 设备名称
     */
    Integer categoryType;


    DeviceCategoryEnum(Integer categoryType) {
        this.categoryType = categoryType;
    }

    private static final Map<Integer, DeviceCategoryEnum> DEVICE_CATEGORY_ENUM_MAP = Arrays.stream(DeviceCategoryEnum.values()).collect(Collectors.toMap(DeviceCategoryEnum::getCategoryType, Function.identity(), (a, b) -> a, CaseInsensitiveMap::new));

    public static DeviceCategoryEnum parseDeviceCategoryEnum(Integer categoryType) {
        return DEVICE_CATEGORY_ENUM_MAP.getOrDefault(categoryType, UNKNOWN);
    }

    public Integer getCategoryType() {
        return categoryType;
    }

    public void setCategoryType(Integer categoryType) {
        this.categoryType = categoryType;
    }
}
